from config import Config

# Celery 配置
broker_url = f'redis://{Config.REDIS_HOST}:{Config.REDIS_PORT}/{Config.REDIS_DB}'  # 使用数据库 10 作为 Broker
result_backend = f'redis://{Config.REDIS_HOST}:{Config.REDIS_PORT}/{Config.Result_DB}'  # 使用数据库 11 作为结果后端

accept_content = ['json']
task_serializer = 'json'
result_serializer = 'json'
result_expires = 60 * 60 * 24  # 结果过期时间为24小时
timezone = 'Asia/Shanghai'
enable_utc = True

worker_concurrency = 8
worker_prefetch_multiplier = 10
worker_max_tasks_per_child = 1000  # 每个 worker 最多执行 1000 个任务后重启

broker_connection_retry_on_startup = True  # Redis服务连接重试是否开启